// 不使用 pinia 的原因是, pinia会代理对象, 导致 pixi 对象无法直接操作
import * as PIXI from 'pixi.js'
const pixis: { [key: string]: PIXI.ContainerChild | PIXI.Text } = {} // 界面PIXI对象
const pixiData: { [key: string]: Record<string, string | number> } = {} // 界面PIXI关联数据
const datas: { [key: string]: Wx.Card.Data } = {} // 卡牌数据
const cards: Record<number, number> = {} // 卡牌ID映射
const spritesheetMap: Map<string, PIXI.Spritesheet> = new Map()
export const getPixi = (name: string | number): PIXI.ContainerChild | PIXI.Text => {
  return pixis[name]
}
export const setPixi = (name: string | number, pixi: PIXI.ContainerChild | PIXI.Text): void => {
  pixis[name] = pixi
}
export const getPixiData = (name: string | number): Record<string, string | number> => {
  return pixiData[name]
}
export const setPixiData = (name: string | number, data: Record<string, string | number>): void => {
  pixiData[name] = data
}
export const getData = (name: string | number): Wx.Card.Data => {
  return datas[name]
}
export const setData = (name: string | number, data: Wx.Card.Data): void => {
  datas[name] = data
}
export const setCardInfo = (cardId: number, uid: number): void => {
  cards[cardId] = uid
}
export const getCardInfo = (cardId: number): number => {
  return cards[cardId]
}
export const getSpritesheetMap = (name: string): PIXI.Spritesheet | undefined => {
  return spritesheetMap.get(name)
}
export const setSpritesheetMap = (name: string, json: PIXI.Spritesheet): void => {
  spritesheetMap.set(name, json)
}
